﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using AMail.Modules.Folders.Interfaces;
using AMail.Modules.Folders.ViewModels;
using Microsoft.Practices.Composite.Regions;
using AMail.Common;
using Microsoft.Practices.Composite.Events;

namespace AMail.Modules.Folders
{
  public class FoldersModule : IModule
  {
    IUnityContainer container;
    IRegionManager regionManager;

    public FoldersModule(IUnityContainer container, IRegionManager regionManager)
    {
      this.container = container;
      this.regionManager = regionManager;
    }

    #region IModule Members

    public void Initialize()
    {
      this.RegisterViewsAndServices();


    }

    #endregion

    private void RegisterViewsAndServices()
    {
      this.container.RegisterType<IFoldersTreeViewModel, FoldersTreeViewModel>();
      var foldersView = this.container.Resolve<FoldersView>();

      regionManager.AddToRegion(RegionNames.Sidebar, foldersView);
    }
  }
}
